import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

/**
 * 查询单个用户
 * @param {*} id
 * @returns
 */
export function getUserByUid(id) {
  return request({
    url: '/user/' + id,
    method: 'get'
  })
}

export function getUserList(data) {
  return request({
    url: '/admin/getAllUser',
    method: 'get',
    params: data

  })
}

/**
 * 修改密码
 * @param {*} data
 * @returns
 */
export function updPassword(data) {
  return request({
    url: '/user/updatePassword',
    method: 'post',
    data
  })
}

/**
 * 获取管理员
 * @param {*} params
 * @returns
 */
export function getAllAdmins(params) {
  return request({
    url: '/admin/getAdminList',
    method: 'get',
    params
  })
}

export function addAdmin(data) {
  return request({
    url: 'admin/addAdmin',
    method: 'post',
    data
  })
}
